from flask import Flask, render_template, request, flash, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine, Column, Integer, Text, DateTime, SMALLINT, Float, Boolean

app = Flask(__name__, instance_relative_config=True, template_folder='templates')
app.config['SECRET_KEY'] = "random string"
HOSTNAME = "127.0.0.1"
PORT = 3306
USERNAME = "root"
PASSWORD = "root"
DATABASE = "flask_games"
# 拼接式创建
app.config[
    'SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOSTNAME}:{PORT}/{DATABASE}?charset=utf8mb4"
# 每次执行会连接到 flask库
db = SQLAlchemy(app)
# 游戏角色
class game_role(db.Model):

    __tablename__ = "game_role"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    game_role_id = db.Column(db.String(32), nullable=True, comment='游戏角色id')
    skin_id = db.Column(db.Text, nullable=True, comment='皮肤id(列表)')
    strength = db.Column(db.Integer, nullable=True, comment='力量(攻击力)')
    strength_percentage = db.Column(db.Integer, nullable=True, comment='力量(攻击力)百分比')
    defense = db.Column(db.Integer, nullable=True, comment='防御')
    defense_percentage = db.Column(db.Integer, nullable=True, comment='防御(百分比)')
    blood = db.Column(db.Integer, nullable=True, comment='血量')
    blood_percentage = db.Column(db.Integer, nullable=True, comment='血量(百分比)')
    speed = db.Column(db.Integer, nullable=True, comment='速度')

    specialZS = db.Column(db.Integer, nullable=True, comment='增伤')
    specialJS = db.Column(db.Integer, nullable=True, comment='减伤')
    specialJNSH = db.Column(db.Integer, nullable=True, comment='技能伤害(百分比)')
    specialJNJS = db.Column(db.Integer, nullable=True, comment='技能减伤(百分比)')
    specialPJ = db.Column(db.Integer, nullable=True, comment='破甲(百分比)')
    specialPJDK = db.Column(db.Integer, nullable=True, comment='破甲抵抗(百分比)')
    specialBJ = db.Column(db.Integer, nullable=True, comment='暴击(百分比)')
    specialBJDK = db.Column(db.Integer, nullable=True, comment='暴击抵抗(百分比)')
    specialBS = db.Column(db.Integer, nullable=True, comment='暴伤(百分比)')
    specialBSDK = db.Column(db.Integer, nullable=True, comment='暴伤抵抗(百分比)')
    specialKZMZ = db.Column(db.Integer, nullable=True, comment='控制命中(百分比)')
    specialJZ = db.Column(db.Integer, nullable=True, comment='精准(百分比)')
    specialMK = db.Column(db.Integer, nullable=True, comment='免控(百分比)')
    specialGD = db.Column(db.Integer, nullable=True, comment='格挡(百分比)')
    specialVIPZS = db.Column(db.Integer, nullable=True, comment='VIP增伤(百分比)')
    specialVIPJS = db.Column(db.Integer, nullable=True, comment='VIP减伤(百分比)')


    USER_SERVICE_TOKEN = db.Column(db.Text, nullable=True, comment='服务标识')  # 小程序通过服务标识来确定小程序数据
    status = db.Column(db.String(32), nullable=True, comment='状态')  # normal  删除destroy

with app.app_context():
    db.create_all()